#include "genlamplabel.h"

#include <QPainter>

GenLampLabel::GenLampLabel(QWidget *parent):
    mode(0),
    QLabel(parent)
{
    setScaledContents(true);
    setGray();
}

void GenLampLabel::drawLamp()
{
    QPixmap pixmap(32, 32);
    QPainter painter(&pixmap);
    QBrush b(Qt::SolidPattern);
    painter.fillRect(0, 0, pixmap.width(), pixmap.height(), QBrush(Qt::black));

    switch (mode) {
    case 0:
        b.setColor(Qt::gray);
        break;
    case 1:
        b.setColor(Qt::yellow);
        break;
    case 2:
        b.setColor(Qt::green);
        break;
    case 3:
        b.setColor(Qt::red);
        break;
    }

    painter.setBrush(b);
    painter.drawEllipse(4, 4, 24, 24);
    setPixmap(pixmap);
}
